package com.ibeeking.found.cop.b.rest.controller.v1;

import com.ibeeking.found.cop.b.rest.service.IFansChannelWelcomeService;
import com.ibeeking.found.cop.b.rest.service.IFansDefaultWelcomeService;
import com.ibeeking.found.cop.service.common.param.FansChannelWelcomeParam;
import com.ibeeking.found.cop.service.common.param.FansDefaultWelcomeParam;
import com.ibeeking.found.cop.service.common.query.FansChannelWelcomeQuery;
import com.ibeeking.found.cop.service.common.query.FansDefaultWelcomeQuery;
import com.ibeeking.found.cop.service.common.vo.FansChannelWelcomeVO;
import com.ibeeking.found.cop.service.common.vo.FansDefaultWelcomeVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.ibeeking.nematos.utils.base.BaseValidationGroup;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName FansWelcomeController
 * @Description
 * @Author ibeeking
 * @Date 2021-06-02 18:15
 **/
@RestController
@RequestMapping("/b/fansWelcome/v1")
public class FansWelcomeController {

    @Resource
    private IFansDefaultWelcomeService fansDefaultWelcomeServiceImpl;

    @Resource
    private IFansChannelWelcomeService fansChannelWelcomeServiceImpl;

    // 默认加粉欢迎词
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询默认加粉欢迎词列表")
    @PostMapping(value = "/fansDefaultList")
    public List<FansDefaultWelcomeVO> fansDefaultList(@RequestBody FansDefaultWelcomeQuery query) {
        return fansDefaultWelcomeServiceImpl.list(query);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "添加默认加粉欢迎词")
    @PostMapping(value = "/fansDefaultAdd")
    public Boolean fansDefaultAdd(@RequestBody @Validated(BaseValidationGroup.Insert.class) FansDefaultWelcomeParam param) {
        return fansDefaultWelcomeServiceImpl.add(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改默认加粉欢迎词")
    @PostMapping(value = "/fansDefaultModify")
    public Boolean fansDefaultModify(@RequestBody @Validated(BaseValidationGroup.Update.class) FansDefaultWelcomeParam param) {
        return fansDefaultWelcomeServiceImpl.modify(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改默认选择项")
    @PostMapping(value = "/fansDefaultSelected/{id}")
    public Boolean fansDefaultSelectedOne(@PathVariable("id") Long id) {
        return fansDefaultWelcomeServiceImpl.updateSelected(id);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改是否启用")
    @GetMapping(value = "/fansDefaultChangeStatus/{id}/{status}")
    public Boolean fansDefaultChangeStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return fansDefaultWelcomeServiceImpl.changeStatus(id, status);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查看默认加粉欢迎词详情")
    @GetMapping(value = "/fansDefaultView/{id}")
    public FansDefaultWelcomeVO fansDefaultView(@PathVariable("id") Long id) {
        return fansDefaultWelcomeServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "删除默认加粉欢迎词")
    @GetMapping(value = "/fansDefaultDel/{id}")
    public Boolean fansDefaultDel(@PathVariable("id") Long id) {
        return fansDefaultWelcomeServiceImpl.del(id);
    }

    // 渠道加粉欢迎词
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询渠道加粉欢迎词列表")
    @PostMapping(value = "/fansChannelList")
    public List<FansChannelWelcomeVO> fansChannelList(@RequestBody FansChannelWelcomeQuery query) {
        return fansChannelWelcomeServiceImpl.list(query);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "添加渠道加粉欢迎词")
    @PostMapping(value = "/fansChannelAdd")
    public Boolean fansChannelAdd(@RequestBody @Validated(BaseValidationGroup.Insert.class) FansChannelWelcomeParam param) {
        return fansChannelWelcomeServiceImpl.add(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改渠道加粉欢迎词")
    @PostMapping(value = "/fansChannelModify")
    public Boolean fansChannelModify(@RequestBody @Validated(BaseValidationGroup.Update.class) FansChannelWelcomeParam param) {
        return fansChannelWelcomeServiceImpl.modify(param);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改是否启用")
    @GetMapping(value = "/fansChannelChangeStatus/{id}/{status}")
    public Boolean fansChannelChangeStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return fansChannelWelcomeServiceImpl.changeStatus(id, status);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查看渠道加粉欢迎词详情")
    @GetMapping(value = "/fansChannelView/{id}")
    public FansChannelWelcomeVO fansChannelView(@PathVariable("id") Long id) {
        return fansChannelWelcomeServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "删除渠道加粉欢迎词")
    @GetMapping(value = "/fansChannelDel/{id}")
    public Boolean fansChannelDel(@PathVariable("id") Long id) {
        return fansChannelWelcomeServiceImpl.del(id);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "从企业微信同步新客户欢迎语")
    @PostMapping(value = "/syncFansChannelWelcomeToWxCp/{id}")
    public Integer syncFansChannelWelcomeToWxCp(@PathVariable("id") Long id) {
        return fansChannelWelcomeServiceImpl.syncFansWelcomeToWxCp(id);
    }

}
